package utils;

import android.text.TextUtils;

import base.BaseApplication;

/**
 * Created by Administrator on 2018/10/11.
 */

public class FaSong {
    /**
     * 01.发送心跳
     */
    public static String xintiao() {

        String xintiao = API.xintiao();
        return xintiao;

    }

    /**
     * 02.查询产品信息
     *
     * @param mima
     */
    public static String chaxunxinxi(String mima) {

        String chanpin;
        if (!TextUtils.isEmpty(mima)) {
            String mi1 = mima.substring(0, 1);
            String mi2 = mima.substring(1, 2);
            String mi3 = mima.substring(2, 3);
            String mi4 = mima.substring(3, 4);
            String mi5 = mima.substring(4, 5);
            String mi6 = mima.substring(5, 6);
            String mi1_16 = JX_Utils.getvalue16(mi1);
            String mi2_16 = JX_Utils.getvalue16(mi2);
            String mi3_16 = JX_Utils.getvalue16(mi3);
            String mi4_16 = JX_Utils.getvalue16(mi4);
            String mi5_16 = JX_Utils.getvalue16(mi5);
            String mi6_16 = JX_Utils.getvalue16(mi6);
            String mimazuizhong = mi1_16 + mi2_16 + mi3_16 + mi4_16 + mi5_16 + mi6_16;
            chanpin = API.chanpin(mimazuizhong);
        } else {
            chanpin = API.chanpin("");
        }
        return chanpin;

    }

    /**
     * 04.预约下发 010101020202030303040404050505060606070707
     * 011220000000000000000000000000000000000000
     * 1 1220 0 0000 0 0000 0 0000 0 00
     *
     * @param yuyuw
     */
    public static String yuyue(String yuyuw) {

        String chanpin;

        String zhouyi = yuyuw.substring(0, 2);
        String yifen = yuyuw.substring(2, 4);
        String yici = yuyuw.substring(4, 6);
        String zhouer = yuyuw.substring(6, 8);
        String erfen = yuyuw.substring(8, 10);
        String erci = yuyuw.substring(10, 12);
        String zhousan = yuyuw.substring(12, 14);
        String sanfen = yuyuw.substring(14, 16);
        String sanci = yuyuw.substring(16, 18);


        String zhousi = yuyuw.substring(18, 20);
        String sifen = yuyuw.substring(20, 22);
        String sici = yuyuw.substring(22, 24);
        String zhouwu = yuyuw.substring(24, 26);


        String wufen = yuyuw.substring(26, 28);
        String wuci = yuyuw.substring(28, 30);
        String zhouliu = yuyuw.substring(30, 32);

        String liufen = yuyuw.substring(32, 34);
        String liuci = yuyuw.substring(34, 36);
        String zhouqi = yuyuw.substring(36, 38);

        String qifen = yuyuw.substring(38, 40);
        String qici = yuyuw.substring(40, 42);


        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
//            String mi0_16 = JX_Utils.getvalue16(mi0);

        String zhouyi_16 = JX_Utils.getvalue16(zhouyi);
        String yifen_16 = JX_Utils.getvalue16(yifen);
        String yici_16 = JX_Utils.getvalue16(yici);

        String zhouer_16 = JX_Utils.getvalue16(zhouer);
        String erfen_16 = JX_Utils.getvalue16(erfen);
        String erci_16 = JX_Utils.getvalue16(erci);


        String zhousan_16 = JX_Utils.getvalue16(zhousan);
        String sanfen_16 = JX_Utils.getvalue16(sanfen);
        String sanci_16 = JX_Utils.getvalue16(sanci);

        String zhousi_16 = JX_Utils.getvalue16(zhousi);
        String sifen_16 = JX_Utils.getvalue16(sifen);
        String sici_16 = JX_Utils.getvalue16(sici);


        String zhouwu_16 = JX_Utils.getvalue16(zhouwu);
        String wufen_16 = JX_Utils.getvalue16(wufen);
        String wuci_16 = JX_Utils.getvalue16(wuci);


        String zhouliu_16 = JX_Utils.getvalue16(zhouliu);
        String liufen_16 = JX_Utils.getvalue16(liufen);
        String liuci_16 = JX_Utils.getvalue16(liuci);

        String zhouqi_16 = JX_Utils.getvalue16(zhouqi);
        String qifen_16 = JX_Utils.getvalue16(qifen);
        String qici_16 = JX_Utils.getvalue16(qici);
        String mimazuizhong = mi0 + zhouyi_16 + yifen_16 + yici_16 + zhouer_16 + erfen_16 + erci_16
                + zhousan_16 + sanfen_16 + sanci_16 + zhousi_16 + sifen_16 + sici_16 +
                zhouwu_16 + wufen_16 + wuci_16 + zhouliu_16 + liufen_16 + liuci_16 +
                zhouqi_16 + qifen_16 + qici_16;


        chanpin = API.yuyuexiafa(mimazuizhong);

        return chanpin;

    }

    /**
     * 03.设置时间
     *
     * @param shijian 2012123102120312
     */
    public static String shezhishijian(String shijian) {

        String chanpin;

        String mi1 = shijian.substring(0, 4);
        String mi2 = shijian.substring(4, 6);
        String mi3 = shijian.substring(6, 8);
        String mi4 = shijian.substring(8, 10);
        String mi5 = shijian.substring(10, 12);
        String mi6 = shijian.substring(12, 14);
        String mi7 = shijian.substring(14, 16);
        int i = Integer.parseInt(mi1) - 2000;
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
//            String mi0_16 = JX_Utils.getvalue16(mi0);
        String mi1_16 = JX_Utils.getvalue16(String.valueOf(i));
        String mi2_16 = JX_Utils.getvalue16(mi2);
        String mi3_16 = JX_Utils.getvalue16(mi3);
        String mi4_16 = JX_Utils.getvalue16(mi4);
        String mi5_16 = JX_Utils.getvalue16(mi5);
        String mi6_16 = JX_Utils.getvalue16(mi6);
        String mi7_16 = JX_Utils.getvalue16(mi7);


        String mimazuizhong = mi0 + mi1_16 + mi2_16 + mi3_16 + mi4_16 + mi5_16 + mi6_16 + mi7_16;
        chanpin = API.shezhishijian(mimazuizhong);

        return chanpin;

    }

    /**
     * 05.工作模式 01 回充
     * 工作模式 02 停机
     */
    public static String gongzuomoshi(String String) {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String xintiao = API.gongzuomoshi(mi0 + String);
        return xintiao;

    }

    /**
     * 06.分区域割草时间 00-59 时间
     */
    public static String fenquyugecao(String String) {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
//        String mi1_16 = JX_Utils.getvalue16(String);
        String mi2_16 = JX_Utils.getvalue16(String);
        String xintiao = API.quyuegecao(mi0 + mi2_16);
        return xintiao;

    }

    /**
     * 07.APP和割草机绑定 888888
     */
    public static String bangding(String old, String news) {
        String mi1 = news.substring(0, 1);
        String mi2 = news.substring(1, 2);
        String mi3 = news.substring(2, 3);
        String mi4 = news.substring(3, 4);
        String mi5 = news.substring(4, 5);
        String mi6 = news.substring(5, 6);
        String mi1_16 = JX_Utils.getvalue16(mi1);
        String mi2_16 = JX_Utils.getvalue16(mi2);
        String mi3_16 = JX_Utils.getvalue16(mi3);
        String mi4_16 = JX_Utils.getvalue16(mi4);
        String mi5_16 = JX_Utils.getvalue16(mi5);
        String mi6_16 = JX_Utils.getvalue16(mi6);
//        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");

        String shuju = old + mi1_16 + mi2_16 + mi3_16 + mi4_16 + mi5_16 + mi6_16;

        String xintiao = API.bangding(shuju);
        return xintiao;

    }

    /**
     * 08.获取割草机Pin Code 888888
     */
    public static String huoqupincode(String news) {

//        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String shuju =   news;
        String xintiao = API.huoqupincode(shuju);
        return xintiao;

    }

    /**
     * 09.设置开机是否需要APP确认  00 不需要
     * 01 需要
     */
    public static String kaijiqueren(String String) {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String xintiao = API.kaijiequeren(mi0 + String);
        return xintiao;

    }

    /**
     * 10.割草机开机APP确认下发  01
     */
    public static String kaijiquerenxiafa() {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String xintiao = API.kaijiquerenxiafa(mi0 + "01");
        return xintiao;

    }

    /**
     * 11.预约失败上报  01
     */
    public static String yuyueshibaishangbao() {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String xintiao = API.yuyueshibaishangbao(mi0 + "01");
        return xintiao;

    }

    /**
     * 最后一个协议
     *
     * @param news
     * @return
     */
    public static String oc(String news) {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");

//        String mi1 = news.substring(0, 1);
//        String mi2 = news.substring(1, 2);
//
//        String mi1_16 = JX_Utils.getvalue16(mi1);
//        String mi2_16 = JX_Utils.getvalue16(mi2);

        String xintiao = API.oc(mi0 + news);
        return xintiao;

    }
    /**
     *
     *  密码回复
     */
    public static String mimahuifu( ) {
        String mi0 = (String) SpfUtils.get(BaseApplication.getInstance(), "mima", "010203040506");
        String xintiao = API.maimahuifu(mi0 + "00");
        return xintiao;

    }

}
